/*<summary>
Created By : Preeti
Created On : 10/18/2008
Class Name : Bed_Mapper
Used In    : 
------------------------------------------------------------------------
Modification Log  
------------------------------------------------------------------------
Created By        Modified By         Remarks                             
-----------       ------------        ----------------------------------
                                                                          
------------------------------------------------------------------------
</summary>*/


using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using Utils;

namespace AdminController
{
    public class Bed_Mapper
    {
        public bool Load_Bed_DATA(string BedID, Bed objBed)
        {
            if (!(objBed == null))
            {
                ezUtilsAdapter DBL = new ezUtilsAdapter();
                int ResultVal;
                bool bresult;
                string wardID;
                string BedNumber;
                string Description;
                string BedType;
                string BedStatus;
                string Remarks;

                wardID = objBed.wardID;
                BedNumber = objBed.BedNumber;
                Description = objBed.Description;
                BedType = objBed.BedType;
                BedStatus = objBed.BedStatus;
                Remarks = objBed.Remarks;

                try
                {
                    ResultVal = DBL.RunSPReturnInteger("SP_SetBed",
                    new SqlParameter("@vchBedID", BedID),
                   new SqlParameter("@vchwardID", wardID),
                     new SqlParameter("@vchBedNumber", BedNumber),
                     new SqlParameter("@vchDescription", Description),
                     new SqlParameter("@vchBedType", BedType),
                     new SqlParameter("@vchBedStatus", BedStatus),
                     new SqlParameter("@vchRemarks", Remarks));
                    if (ResultVal == 0) { bresult = true; } else { bresult = false; } return bresult;
                }
                catch (SqlException ex)
                {
                    string errorMessage = string.Format(
                        "An Error Occurred While Loading the Bed Information to the DB. Message: {0}", ex.Message);
                    //throw new MappingException(errorMessage, ex);}
                    return false;
                }
                finally
                {
                    DBL.Dispose();
                }
            }

            else { return false; }
        }

        public void Dispose()
        {
            this.Dispose(true);
            System.GC.SuppressFinalize(this);
        }

        private void Dispose(bool disposing)
        {
        }


    }
}